<template>
  <div v-loading="loading" class="app-container">
    <div class="head-container">
      <searchForm ref="searchForm" :parent="currentObject" />
    </div>
    <div style="padding-top:5px">
      <el-button size="mini" type="danger" style="float:right;margin-bottom:5px;margin-left:0px;" icon="el-icon-delete" round @click="doDeleteItem">作废</el-button>
      <el-button type="primary" size="mini" style="float:right;margin-bottom:5px;margin-left:0px;" icon="el-icon-monitor" round @click="batchValidate">校验</el-button>
      <downloadBnt ref="downloadBnt" :parent="currentObject" />
      <uploadBnt ref="uploadBnt" :parent="currentObject" />
      <cancel ref="cancel" :parent="currentObject" />
      <el-button type="primary" size="mini" style="float:right;margin-bottom:5px;margin-left:0px;" icon="el-icon-refresh-left" round @click="toQuery">刷新</el-button>
      <dataGrid ref="dataGrid" :parent="currentObject" />
    </div>
    <activeForm ref="activeForm" :parent="currentObject" />
  </div>
</template>

<script>
import activeForm from '@/views/active-item/validate/validate-active'
import searchForm from '@/views/active-item/search-form'
import downloadBnt from '@/views/active-item/file/download'
import uploadBnt from '@/views/active-item/file/upload'
import dataGrid from '@/views/active-item/data-grid'
import initData from '@/utils/initData'
import common from '@/api/active-global'
import cancel from '@/views/active-item/file/cancel'
import { doBatchValidate } from '@/utils/activeItemUtil'
import { doDeleteItem } from '@/utils/changeItem'

export default {
  components: { activeForm, searchForm, dataGrid, downloadBnt, uploadBnt, cancel },
  mixins: [initData],
  data() {
    return {
      currentObject: this,
      ids: [],
      loading: false,
      itemStatuses: [
        { value: 2, name: '待数据校验' },
        { value: 3, name: '数据校验中' },
        { value: 4, name: '数据校验成功' },
        { value: -4, name: '数据校验失败' },
        { value: -6, name: 'BPMS审批驳回' },
        { value: -10, name: 'MDA审批驳回' },
        { value: -11, name: 'Item File审批驳回' },
        { value: common.ITEM_STATUS_DELETE, name: '已作废' }
      ],
      changeType: common.itemType,
      addOrUpdate: null
    }
  },
  created() {
    this.$nextTick(() => {
      this.init()
    })
  },
  methods: {
    doDeleteItem,
    beforeInit() {
      this.url = common.basePath + '/queryValidateItemTypeModityList'
      this.params.pageNum = this.page
      this.params.pageSize = this.size
      this.params.changeType = this.changeType
      return true
    },
    // 详情触发
    toItemInfo(item) {
      const _this = this.$refs.activeForm
      _this.title = '商品转类型-详情页面'
      _this.itemInfo = JSON.parse(item.itemInfo)
      _this.itemInfo.vendorItemInfo = JSON.parse(item.vendorItemInfo)
      _this.itemStatus = item.itemStatus
      _this.buyerId = item.buyerId
      _this.id = item.id
      this.addOrUpdate = 'updateItemInfo'
      _this.dialog = true
    },
    // 批量校验
    batchValidate() {
      doBatchValidate(this)
    },
    // 查询
    toQuery() {
      this.page = 0
      this.currentPage = 1
      this.init()
      this.$refs.dataGrid.doClearSelection()
    }
  }
}
</script>
